package com.itheima.app.controller;

import com.itheima.app.manager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {
    @Autowired
    private SettingManager settingManager;

    //查询通用设置
    @GetMapping("/users/settings")
    public ResponseEntity findSettingVo(){
        return settingManager.findSettingVo();
    }
    //修改陌生人问题
    @PostMapping("/users/questions")
    public void setQuestion(@RequestBody Map<String ,String >map){
        String content = map.get("content");
        settingManager.setQuestion(content);
    }
    //修改通知权限设置
    @PostMapping("/users/notifications/setting")
    public void setNotification(@RequestBody Notification notification){
        settingManager.setNotification(notification);
    }
    //查询黑名单
    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(@RequestParam(value = "page",defaultValue = "1")Integer pageNum,
                                              @RequestParam(value = "pagesize",defaultValue = "10")Integer pageSize){

        return  settingManager.findBlackListByPage(pageNum,pageSize);
    }
    //移除黑名单
    @DeleteMapping("/users/blacklist/{uid}")
    public void removeBlackList(@PathVariable("uid") Long blackUserId){
      settingManager.removeBlackList(blackUserId);
    }
    //发送修改手机的验证码
    @PostMapping("/users/phone/sendVerificationCode")
    public void sendVerificationCode(){
      settingManager.sendVerificationCode();
    }
    //检测修改手机的验证码
    @PostMapping("/users/phone/checkVerificationCode")
    public ResponseEntity checkVerificationCode(@RequestBody Map<String ,String > map){
        String code = map.get("verificationCode");
        return settingManager.checkVerificationCode(code);
    }
    //修改手机号
    @PostMapping("/users/phone")
    public void setPhone(@RequestBody Map<String ,String > map){
        String phone = map.get("phone");
        settingManager.setPhone(phone);
    }

}
